﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security;
using System.Text;

public static class SecureStringExtensionMethods
{
    public static string ToClrString(this SecureString s)
    {
        var ptr = Marshal.SecureStringToBSTR(s);

        try
        {
            return Marshal.PtrToStringBSTR(ptr);
        }
        finally
        {
            Marshal.FreeBSTR(ptr);
        }
    }
}
